var WDK_ROOT = 'wdk';				//WDK根目录
var WDK_Timeout = 50000;			//ajax超时时间
var WDK_skin = "gray";	//metro-blue	//默认加载的皮肤:default   food


var _DEFAULT_containerid = "layout_content";				//默认ID：grid
var _DEFAULT_gridid = "_DEFAULT_gridid";					//默认ID：grid
var _DEFAULT_gridcode = "_DEFAULT_gridcode";				//默认ID：grid

var _ID_grid_contextmenu = "_ID_grid_contextmenu";			//右键菜单div的ID
var _ID_query_scheme = "_ID_query_scheme";					//查询方案的查询界面容器的ID


var _METHOD = new Object();					//方法注册事件，该参数在顶层有效
var _KEYPRESS = new Object();				//按键注册事件，该参数在顶层有效
var _INPUTPOP = new Object();				//inputpop参数传递缓存对象

var _JSON_ENCODE_SPLIT = "___";				//JSON参数引号替换符
//var _OSS = "http://192.168.1.167/fileserver";
var _OSS = "http://menheyoss.oss-cn-hangzhou.aliyuncs.com";
//程序应用名称
var _APPName = "tolspp";

/****************************************
 * 
 * 系统加载初始化
 * 
 */
var js=document.scripts;
var jsRoot;
for(var i=0;i<js.length;i++){
 if(js[i].src.indexOf("wdk.js")>-1){
   jsRoot=js[i].src.substring(0,js[i].src.lastIndexOf("/")+1);
 }
}

//加载CSS样式
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/skins/'+WDK_skin+'/wdk.css">');
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/skins/'+WDK_skin+'/easyui.css">');
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/public.css">');
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/icon.css">');
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/swfupload.css">');

//更换为扁平化风格增加的css
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/main_dark.css">');
document.write('<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">');
document.write('<link rel="stylesheet" type="text/css" href="'+WDK_ROOT+'/core/css/animate.css">');
//判断IE版本
var ua = navigator.userAgent;
var s = "MSIE";
var version = 0;
var i;
var isIE = false;
if ((i = ua.indexOf(s)) >= 0) {
	isIE = true;
	version = parseFloat(ua.substr(i + s.length));
}


if(isIE&&version<9){
	document.write('<script language="javascript" src="'+jsRoot+'lib/jquery.1.8.0.js"></script>');
	document.write('<script language="javascript" src="'+jsRoot+'lib/html5.js"></script>');
}else{
	document.write('<script language="javascript" src="'+jsRoot+'lib/jquery.2.0.0.js"></script>');
}


document.write('<script language="javascript" src="'+jsRoot+'lib/easyui.1.3.4/jquery.easyui.min.js?v2"></script>');
document.write('<script language="javascript" src="'+jsRoot+'lib/easyui.1.3.4/locale/easyui-lang-zh_CN.js"></script>');

document.write('<script language="javascript" src="'+jsRoot+'lib/fullcalendar1.6.4/fullcalendar.js">');
document.write('<script language="javascript" src="'+jsRoot+'lib/plugin/jquery.cookie.js"></script>');
document.write('<script language="javascript" src="'+jsRoot+'lib/plugin/jquery.hotkeys.js"></script>');


document.write('<script language="javascript" src="'+jsRoot+'lib/zclip/jquery.zclip.js"></script>');
document.write('<script language="javascript" src="'+jsRoot+'lib/swfupload/swfupload.js"></script>');
document.write('<script language="javascript" src="'+jsRoot+'lib/swfupload/swfupload.queue.js"></script>');
document.write('<script language="javascript" src="'+jsRoot+'lib/jwplayer/jwplayer.js"></script>');


document.write('<script language="javascript" src="'+jsRoot+'lib/ckeditor.4.2/ckeditor.js"></script>');

document.write('<script language="javascript" src="'+jsRoot+'wdk.extend.src.js"></script>');
document.write('<script language="javascript" src="'+jsRoot+'wdk.util.js"></script>');
document.write('<script language="javascript" src="'+jsRoot+'public.js"></script>');

document.write('<script language="javascript" src="'+jsRoot+'jquery.slimscroll.min.js"></script>');





/******************************************************
 * 定义通用方法和公用方法
 * @param theme
 * @return
 *****************************************************/
function setTheme(theme){
	WDK_theme = theme;
}

/**
 * 粘贴
 * @param gridcode
 * @param gridid
 * @param type		0-当前行的下一行  1-当前行的上一行  2-第一行   3-最后一行
 * @return
 */
function _handler_grid_paste(gridcode,gridid,idField,type){
	var _enableedit = $('#'+gridid).datagrid('options').enableedit;
	if(_enableedit){
		//alert('允许编辑');
	}else{
	//	alert('当前报表不可编辑');
		$.getRoot().$.messager.alert('信息提示','当前报表不可编辑','warning');
		return false;
	}
	var _copyrows = $('#'+gridid).datagrid('options').copyrows;
	var selectedrow = $("#"+gridid).datagrid("getSelected");
    var rowIndex = $("#"+gridid).datagrid("getRowIndex", selectedrow);
	switch(type){
		case '1':
			for(var i=0;i<_copyrows.length;i++){
				var _row = _copyrows[i];
				_row[idField] = $.getUUID();
				$("#"+gridid).datagrid("insertRow",{index:rowIndex+i,row:_row});
			}
			break;
		case '2':
			for(var i=0;i<_copyrows.length;i++){
				var _row = _copyrows[i];
				_row[idField] = $.getUUID();
				$("#"+gridid).datagrid("insertRow",{index:i,row:_row});
			}
			break;
		case '3':
			for(var i=0;i<_copyrows.length;i++){
				var _row = _copyrows[i];
				_row[idField] = $.getUUID();
				$("#"+gridid).datagrid("appendRow",_row);
			}
			break;
		default:
			for(var i=0;i<_copyrows.length;i++){
				var _row = _copyrows[i];
				_row[idField] = $.getUUID();
				$("#"+gridid).datagrid("insertRow",{index:rowIndex+i+1,row:_row});
			}
			break;
	}
	
	
}

//导出当前页到excel
function _handler_grid_export2excel_page(gridcode,gridid,mergetype){
	$.grid_export_excel({
		eptype:'0',
		mergetype:mergetype,
		gridcode:gridcode,
//		captionurl:captionurl,
		gridid:gridid
	});
}
//导出全部
function _handler_grid_export2excel_total(gridcode,gridid,mergetype){
	$.grid_export_excel({
		eptype:'1',
		mergetype:mergetype,
		gridcode:gridcode,
//		captionurl:captionurl,
		gridid:gridid
	});
}

//导出空模板
function _handler_grid_export2excel_template(gridcode,gridid){
	$.grid_export_excel({
		eptype:'2',
		gridcode:gridcode,
//		captionurl:captionurl,
		gridid:gridid
	});
}
//数据导入
function _handler_grid_import(gridcode,gridid){
	$.grid_import({
		gridcode:gridcode,
//		captionurl:captionurl,
		gridid:gridid
	});
}
function grid_import_callback(jparam){
	$.grid_import_callback(jparam);
}

//表格设置
function _handler_grid_formatset(gridcode,gridid,containerid){
	var _wid = $.getID();
	var _mid = $.method_reg(window,"_callback_gridreload");

	//读取所有列宽
	var _colWidth = $.grid_getColWidth({id:containerid});
	var strColWidth = $.json2str(_colWidth);
	strColWidth = strColWidth.replace(/\'/ig,"").replace(/\"/ig,"");
	//alert(WDK_ROOT+'/module/frame/public/grid_format.jsp?gridcode='+gridcode+"&mid="+_mid+"&gid="+gridid+"&colwidth="+strColWidth)
	$.openWin({
		id:_wid,
		title:'表格设置',
		height:500,
		width:800,
		modal:true,
		type:'url',
		url:WDK_ROOT+'/module/public/grid_format.jsp?gridcode='+gridcode+"&mid="+_mid+"&gid="+gridid+"&colwidth="+strColWidth
	});
}
//表格设置完成后的刷新，
function _callback_gridreload(jparam){
	//alert('_callback_gridreload   jparam.id='+jparam.id)
	//$('#'+jparam.id).datagrid('reload');
	document.location.reload();
}


//恢复默认设置
function _handler_grid_formatload(gridcode,gridid){
//	alert('_handler_grid_formatload('+gridcode+','+gridid+')');
	var _data = {
					gridcode:gridcode
				};
	$.cuajax({
		url: 'wdk?action=wdk.public&method=grid_resetFormat&ajaxparam='+new Date().getTime(),
		method:"post", 
		timeout:WDK_Timeout,
		data:_data,   
		success:function(result) {
			var jres = $.str2json(result);
//			alert(jres.desc);
			$.getRoot().$.messager.alert('信息提示',jres.desc);
			document.location.reload();
		},
		error:function(result){
//			alert('网络错误！result='+result);
			$.getRoot().$.messager.alert('信息提示',result,'error');
		}
	});
	
	
}


/**
 * 封装当前页取值的公用方法
 *    该方法返回的id
 * @param jparam
 * @return
 */
function _handler_getFieldValue(jparam){
	var _id = jparam.id;
	var _type = jparam.type;
	var _vo = new Object();
	_vo.value_id = '';
	_vo.value_text = '';
	_vo.value_value = '';
	switch(_type){
		case 'validatebox':
			_vo.value_id = $("#"+_id).val();
			break;
		case 'hidden':
			_vo.value_id = $("#"+_id).val();
			break;
		case 'combobox':
			_vo.value_id = $("#"+_id).combobox('getValue');
			_vo.value_text = $('#'+_id).combobox('getText');
			break;
		case 'datebox':
			_vo.value_id = $("#"+_id).datebox('getValue');
			break;
		case 'datetimebox':
			_vo.value_id = $("#"+_id).datetimebox('getValue');
			break;
		case 'inputpop':
			_vo.value_id = $("#iph_id_"+_id).val();
			_vo.value_text = $("#iph_text_"+_id).val();
			_vo.value_value = $("#iph_value_"+_id).val();
			break;
		default:
			break;
	}
	return _vo;
}


/***************************************
 * 
 * 		可编辑grid的表格操作方法
 * 
 **************************************/
//var editIndex = undefined;
//结束编辑
//function _handler_grid_toolbar_endEditing(_id){
//	
////   if (editIndex == undefined){return true;}
////	var selectedrow = $("#"+_id).datagrid("getSelected");
//  //  var editIndex = $("#"+_id).datagrid("getRowIndex", selectedrow);
//	var _editrowindex = $('#'+_id).datagrid('options').editrowindex;
//	if (-1==_editrowindex){return true;}
//    if ($('#'+_id).datagrid('validateRow', _editrowindex)){
//    //    var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'});
//    //    var productname = $(ed.target).combobox('getText');
//    //    $('#'+_id).datagrid('getRows')[editIndex]['productname'] = productname;
//    	
//        $('#'+_id).datagrid('endEdit', _editrowindex);
//  //      $('#'+_id).datagrid('options').editrowindex = -1;
//        return true;
//    } else {
//        return false;
//    }
//}
//单击
//function _handler_grid_onClickRow(_id,index){
//	_handler_grid_toolbar_endEditing(_id);
//	//editIndex = index;
////	$("#"+_id).datagrid("options").editrowindex = index;
//	$('#'+_id).datagrid('selectRow', index);
//}
//双击
//function _handler_grid_onDblClickRow(_id,index){
//  //  if (editIndex != index){
//        if (_handler_grid_toolbar_endEditing(_id)){
////            $('#'+_id).datagrid('selectRow', index).datagrid('beginEdit', index);
//           // editIndex = index;
//        	$("#"+_id).datagrid("options").editrowindex = index;
//            $.grid_editor_beginEdit({id:_id,type:'edit',rowIndex:index});
//        } else {
//            $('#'+_id).datagrid('selectRow', index);
//        }
// //   }
//}
//新增
//function _handler_grid_toolbar_append(_id,_data,_beginedit){
//	  if (_handler_grid_toolbar_endEditing(_id)){
//		  //if(true){
//		  	if(!_data){
//		  		_data = {};
//		  	}
//		  	//防止引用
//			var mydata = new Object();
//		  	for(var att in _data){
//		  		if('object'==typeof(_data[att])){
//		  			mydata[att] = _data[att].show+'<input type=hidden value="'+_data[att].show+'|||'+_data[att].hidden+'">';
//		  		}else{
//		  			mydata[att] = _data[att];
//		  		}
//		  	}
//	        $('#'+_id).datagrid('appendRow',mydata);
//	        
//	        if(true==_beginedit){
//	        	_handler_grid_toolbar_endEditing(_id);
//	        	var _index = $('#'+_id).datagrid('getRows').length-1;
//	        	$("#"+_id).datagrid("options").editrowindex = _index;
//	        	$.grid_editor_beginEdit({id:_id,type:'append',rowIndex:_index});
//	        }
//	    }
//}

////删除
//function _handler_grid_toolbar_remove(_id){
//	var _index = $("#"+_id).datagrid("options").editrowindex;
//	if (-1 == _index){return;}
//    $('#'+_id).datagrid('cancelEdit', _index)
//            .datagrid('deleteRow', _index);
//    $("#"+_id).datagrid("options").editrowindex = -1;
//}
//接受
function _handler_grid_toolbar_submit(_id,_submiturl,_gridcode){
	if (_handler_grid_toolbar_endEditing(_id)){
		var jrows = [];
		
		$('#'+_id).datagrid('acceptChanges');
		var rows = $('#'+_id).datagrid('getRows');
		for(var i=0;i<rows.length;i++){
			var row = rows[i];
			var jrow = new Object();
			for(var att in row){
				jrow[att] = row[att];
			}
			jrows.push(jrow);
		}
		
		//保存提交
		 var _data = {
				 		jrows:$.json2str(jrows),
				 		gridcode:_gridcode
		 			};
		$.cuajax({
		  	url:_submiturl+'&ajaxparam='+new Date().getTime(),
			method:"post", 
			timeout:WDK_Timeout,
			data:_data,   
			success:function(result) {
				var jres = eval("("+result+")");
//				alert('返回值：'+result);
				$.getRoot().$.messager.alert('信息提示','返回值：'+result);
			},
			error:function(result){
//				alert('网络错误！result='+result);
				$.getRoot().$.messager.alert('信息提示','网络错误：'+result,'error');
			}
		});
		
	}
}
////撤销
//function _handler_grid_toolbar_reject(_id){
//	$('#'+_id).datagrid('rejectChanges');
////	$("#"+_id).datagrid("options").editrowindex = -1;
//}
////获取改变的行
//function _handler_grid_toolbar_getChanges(_id){
//	var rows = $('#'+_id).datagrid('getChanges');
//    alert(rows.length+' rows are changed!');
//    return rows;
//}


function grid_editor_onClick(event){
	var event = event || window.event;
	var jparam = event.data;
	var _ed = jparam.ed;
	var _id = jparam.id;
	var _rowIndex = jparam.rowIndex;
	var _keyUp_mid = jparam.keyUp_mid;
	
	//将当前编辑器的值设置回行
	//var _value = $.grid_getEditorValue(_ed);
	//var _data = new Object();
	//_data[_ed.field] = _value;
	//$.grid_setData({id:jparam.id,rowIndex:_rowIndex,data:_data});
	
	//如果有自定义keyup事件，则调用
	if(_keyUp_mid&&_keyUp_mid.length>30){
		$.method_call(_keyUp_mid,event);
	}
	
	
	var pos = -1;
	if(event.keyCode==13){
		var eds = $('#'+_id).datagrid('getEditors', _rowIndex);
		for(var i=0;i<eds.length;i++){
			if(eds[i].field == _ed.field){
				pos = i;
				break;
			}
		}
	}
	$.grid_editor_next({id:_id,rowIndex:_rowIndex,edpos:pos});
};
	
	
/***************************************
 * 
 * 		inputpop控件操作方法
 * 
 **************************************/
function _inputpop_onfocusin(id){
	//alert('_inputpop_onfocusin');
	var _value = $("#"+id).val();
	var _ipt_text = $("#iph_text_"+id).val();
	var _ipt_value = $("#iph_value_"+id).val();
	$("#"+id).val(_ipt_value);
}
function _inputpop_onfocusout(id){
//	alert('_inputpop_onfocusout');
	var _value = $("#"+id).val();
	if('true'==$('#'+id).attr('isrequired')){
		if(_value){
			$('#'+id).attr('class','inputpop_input');
		}else{
			$('#'+id).attr('class','inputpop_input_required');
		}
	}
	var _ipt_text = $("#iph_text_"+id).val();
	var _ipt_value = $("#iph_value_"+id).val();
//	alert('out  _value='+_value+'  _ipt_text='+_ipt_text+'  _ipt_value='+_ipt_value)
	if(_value!=_ipt_value){
		$("#iph_text_"+id).val(_value);
		$("#iph_value_"+id).val(_value);
		$("#iph_id_"+id).val(_value);
	}else{
		$("#"+id).val(_ipt_text);
	}
	
}
/*
//可编辑grid的单元格点击
function _handler_grid_inputpop(mid,jsonstr){
	var joptions = $.str2json(jsonstr);
	var _wid = $.getID();
	var _url = joptions.url.match(/\?/) ?joptions.url+"&jsonstr="+jsonstr:joptions.url+"?jsonstr="+jsonstr;
	_url += "&mid="+mid+"&wid="+_wid;
	$.openWin({
		id:_wid,
		title:joptions.title,
		height:joptions.height?joptions.height:300,
		width:joptions.width?joptions.width:600,
		modal:true,
		type:'url',
		url:_url
		
	});
}

//可编辑grid编辑完成回调
function _callback_inputpop_default(jparam,methodparam){
	try{
		$(methodparam.container).find('input.inputpop_input').val(jparam.value);
		$(methodparam.container).find('input.inputpop_hidden_name').val(jparam.name);
		$(methodparam.container).find('input.inputpop_hidden_value').val(jparam.value);
	}catch(e){
		alert(e.message);
	}
}
*/
/*
function _inputpop_openwin_grid_blur(ipt,mid,strparam){
//	alert('_inputpop_openwin_grid_blur');
	var jparam =$.str2json(strparam);
	if(jparam.gridid){
		var selectedrow = $("#"+jparam.gridid).datagrid("getSelected");
        var rowIndex = $("#"+jparam.gridid).datagrid("getRowIndex", selectedrow);
        var editors = $('#'+jparam.gridid).datagrid('getEditors', rowIndex);
        for(var i=0;i<editors.length;i++){
        	var ed = editors[i];
        	if(ed.field ==jparam.field){
        		var _value_id = $(ipt).parent().parent().find('input.inputpop_hidden_value').val();
        		if(!_value_id||_value_id!=$(ipt).val()){
        			ed.target.val($(ipt).val());
        		}
        	}
        }
        jparam.row = selectedrow;
	}
}
*/

function _inputpop_onkeydown_grid(ipt,event,mid,strparam){
	//对屏蔽的特殊按键进行处理
	var _keyCode = event.which;
	var _key = '';

	var isCtrl = false;
	var isAlt = false;
	var isShift = false;
	if(event.ctrlKey){
		isCtrl = true;
	}
	if(event.altKey){
		isAlt = true;
	}
	if (event.shiftKey){
		isShift = true;
	}
	if(_keyCode&&16!=_keyCode&&17!=_keyCode&&18!=_keyCode){
		if(isCtrl){
			_key += 'ctrl';
		}
		if(isAlt){
			if(_key.length>0){
				_key += '_';
			}
			_key += 'alt';
		}
		if(isShift){
			if(_key.length>0){
				_key += '_';
			}
			_key += 'shift';
		}
		if(_key.length>0){
			_key += '_';
		}
		switch(_keyCode){
			case 112:_key += 'f1';break;
			case 113:_key += 'f2';break;
			case 114:_key += 'f3';break;
			case 115:_key += 'f4';break;
			case 116:_key += 'f5';break;
			case 117:_key += 'f6';break;
			case 118:_key += 'f7';break;
			case 119:_key += 'f8';break;
			case 120:_key += 'f9';break;
			case 121:_key += 'f10';break;
			case 122:_key += 'f11';break;
			case 123:_key += 'f12';break;
			case 27:_key += 'esc';break;
			case 192:_key += '`';break;
			case 189:_key += '-';break;
			case 187:_key += '=';break;
			case 8:_key += 'back';break;
			case 9:_key += 'tab';break;
			case 219:_key += '[';break;
			case 221:_key += ']';break;
			case 220:_key += '\\';break;
			case 20:_key += 'caps';break;
			case 186:_key += ';';break;
			case 222:_key += '\'';break;
			case 13:_key += 'enter';break;
			case 188:_key += ',';break;
			case 190:_key += '.';break;
			case 191:_key += '/';break;
			case 37:_key += 'left';break;
			case 38:_key += 'up';break;
			case 39:_key += 'right';break;
			case 40:_key += 'down';break;
			case 32:_key += 'space';break;
			default:_key += String.fromCharCode(_keyCode).toLowerCase();break;
		}
	}
	
	//取得当前inpupop控件的值
	var jparam = $.str2json(strparam);
	var _editrowindex = $("#"+jparam.gridid).datagrid("options").editrowindex;
	var selectedrow = $.grid_getRow({id:jparam.gridid,rowIndex:_editrowindex});
//	var _v = new Object();
	jparam.value_id = selectedrow[jparam.valueField?jparam.valueField:jparam.textField];
	jparam.value_text = ipt.value;
	
	
	//调用事件句柄，回车事件单独处理
	for(var shortkey in jparam.keyHandler){
		if(shortkey==_key&&'enter'!=_key){
			var mid = jparam.keyHandler[shortkey];
			$.method_call(mid,jparam);
		}
	}
	//如果是回车事件，则弹出界面
	if('enter'==_key){
		var _iptvalue = $(ipt).val();
		_inputpop_openwin_grid(null,mid,strparam,_iptvalue);
	}
	//阻止事件传递,此处允许继续传递事件，因为grid也有可能有键盘事件，需要通过此事件检测并触发
//	event.stopPropagation();  
	
}

//可编辑grid的单元格点击
function _inputpop_openwin_grid(ipt,mid,strparam,iptvalue){
	var jparamtmp = $.str2json(strparam);
	var jparam = jparamtmp;
	
	if(jparamtmp.onBeforeOpen){
		jparam = $.method_call(jparamtmp.onBeforeOpen,jparamtmp);
		if(!jparam||false==jparam){
			return false;
		}
	}
	var opentype = jparam.type;
	var valueField = jparam.valueField?jparam.valueField:jparam.field;
	//构建行数据集
	if(jparam.gridid){
		jparam.row = new Object();
		var _editrowindex = $("#"+jparam.gridid).datagrid("options").editrowindex;
		var selectedrow = $.grid_getRow({id:jparam.gridid,rowIndex:_editrowindex});
		for(var att in selectedrow){
			
			if(opentype != "tree"){
				var str = selectedrow[att];
				if(str){
					jparam.row[att] = str;
				}else{
					jparam.row[att] = '';
				}
			}else if(att == valueField){
				var str = selectedrow[att];
				if(str){
					jparam.row[att] = str;
				}else{
					jparam.row[att] = '';
				}
			}
		}
        var editors = $('#'+jparam.gridid).datagrid('getEditors', _editrowindex);
        for(var i=0;i<editors.length;i++){
        	var ed = editors[i];
        	if(opentype != "tree"){
        		jparam.row[ed.field] = ed.target.find('input.inputpop_input').val();
			}else if(ed.field == valueField){
				jparam.row[ed.field] = ed.target.find('input.inputpop_input').val();
			}
        	
        }
	}
	
	//构建传递参数
	if(!jparam.queryParams){
		jparam.queryParams = new Object();
	}
	var _paramField = jparam.paramField?jparam.paramField:null;
	if(_paramField&&_paramField.length>0){
		var arr = _paramField.split(",");
		for(var i=0;i<arr.length;i++){
			var att = arr[i];
			jparam.queryParams[att] = jparam.row[att];
		}
	}
	
	var _value_id = jparam.row[valueField];
	var _value_text = "";
	if(null!=iptvalue&&""!=iptvalue){
		_value_text = iptvalue;
	}else{
		if(null!=ipt){
			_value_text = $(ipt).parent().parent().find('input.inputpop_input').val();
		}
	}
	var _iph_datas="";
	if(opentype == "tree"){
		jparam.row[valueField]="";
		_iph_datas = {};
		_iph_datas.value_id = _value_id;
		_iph_datas.value_text = _value_text;
		
		_iph_datas.value_id_old = _value_id;
		_iph_datas.value_text_old = _value_text;
		
	}else{
		jparam.value_id = _value_id;
		jparam.value_text = _value_text;
		
		jparam.value_id_old = _value_id;
		jparam.value_text_old = _value_text;
	}
	
	
	
	
	var _wid = $.getID();
	var _url = WDK_ROOT+"/module/public/inputpop.jsp?mid="+mid;
	
	var _height = jparam.height?jparam.height:400;
	var _width = jparam.width?jparam.width:300;
	var _title = jparam.title?jparam.title:'请选择';
	$.openWin({
		id:_wid,
		title:_title,
		height:_height,
		width:_width,
		modal:true,
		type:'url',
		url:_url,
		param:jparam,
		iph_datas:_iph_datas
	});
}

//可编辑grid编辑完成回调
function _callback_inputpop_openwin_grid(jparam,methodparam){
	try{
		var valueField = jparam.valueField?jparam.valueField:jparam.field;
		var _value = jparam.value_id;
		var _text = jparam.value_text;
		var _value_old = jparam.value_id_old;
		var _text_old = jparam.value_text_old;
		
		$(methodparam.container).find('input.inputpop_input').val(_text);
	//	$(methodparam.container).find('input.inputpop_hidden_name').val(jparam.value_text);
	//	$(methodparam.container).find('input.inputpop_hidden_value').val(jparam.value_id);
		var _data = new Object();
		_data[valueField] = _value;
		$.grid_setData({id:jparam.gridid,data:_data});
		var _edpos = -1;
		var _rowIndex = -1;
		var _id = null;
		if(jparam.gridid){
			_id = jparam.gridid;
			jparam.row = new Object();
			var selectedrow = $.grid_getSelected({id:jparam.gridid});//$("#"+jparam.gridid).datagrid("getSelected");
			for(var att in selectedrow){
				jparam.row[att] = selectedrow[att];
			}
			//var selectedrow = $("#"+jparam.gridid).datagrid("getSelected");
	       // _rowIndex = $("#"+jparam.gridid).datagrid("getRowIndex", selectedrow);
			var _rowIndex = $("#"+jparam.gridid).datagrid("options").editrowindex;
	        var editors = $('#'+jparam.gridid).datagrid('getEditors', _rowIndex);
	        for(var i=0;i<editors.length;i++){
	        	var ed = editors[i];
	        	if(ed.field ==jparam.field){
	        		//ed.target.val(jparam.value_id);
	        		_edpos = i;
	        		jparam.row[ed.field] = jparam.value_id;
	        		break;
	        	//	alert(ed.field+"="+jparam.value_id)
	        	}
	        }
		}
	//	alert('_callback_inputpop_openwin_grid  '+$.json2str(jparam.row));
		if(_id){
			$.grid_editor_next({id:_id,edpos:_edpos,rowIndex:_rowIndex});
		}
		if((_value!=_value_old)||(_text!=_text_old)){
			$.method_call(jparam.onChangeValue,jparam);
		}
		if(jparam.callback){
			$.method_call(jparam.callback,jparam);
//			eval(jparam.callback+'('+$.json2str(jparam)+')');
		}
		
	}catch(e){
//		alert(e.message);
		$.messager.alert('信息提示','表格编辑错误:'+e.message,'warning');
	}
}



function _inputpop_onkeydown(id,ipt,event,strparam){
//	_inputpop_onfocusout(id);
	
	//对屏蔽的特殊按键进行处理
	var _keyCode = event.which;
	var _key = '';

	var isCtrl = false;
	var isAlt = false;
	var isShift = false;
	if(event.ctrlKey){
		isCtrl = true;
	}
	if(event.altKey){
		isAlt = true;
	}
	if (event.shiftKey){
		isShift = true;
	}
	if(_keyCode&&16!=_keyCode&&17!=_keyCode&&18!=_keyCode){
		if(isCtrl){
			_key += 'ctrl';
		}
		if(isAlt){
			if(_key.length>0){
				_key += '_';
			}
			_key += 'alt';
		}
		if(isShift){
			if(_key.length>0){
				_key += '_';
			}
			_key += 'shift';
		}
		if(_key.length>0){
			_key += '_';
		}
		switch(_keyCode){
			case 112:_key += 'f1';break;
			case 113:_key += 'f2';break;
			case 114:_key += 'f3';break;
			case 115:_key += 'f4';break;
			case 116:_key += 'f5';break;
			case 117:_key += 'f6';break;
			case 118:_key += 'f7';break;
			case 119:_key += 'f8';break;
			case 120:_key += 'f9';break;
			case 121:_key += 'f10';break;
			case 122:_key += 'f11';break;
			case 123:_key += 'f12';break;
			case 27:_key += 'esc';break;
			case 192:_key += '`';break;
			case 189:_key += '-';break;
			case 187:_key += '=';break;
			case 8:_key += 'back';break;
			case 9:_key += 'tab';break;
			case 219:_key += '[';break;
			case 221:_key += ']';break;
			case 220:_key += '\\';break;
			case 20:_key += 'caps';break;
			case 186:_key += ';';break;
			case 222:_key += '\'';break;
			case 13:_key += 'enter';break;
			case 188:_key += ',';break;
			case 190:_key += '.';break;
			case 191:_key += '/';break;
			case 37:_key += 'left';break;
			case 38:_key += 'up';break;
			case 39:_key += 'right';break;
			case 40:_key += 'down';break;
			case 32:_key += 'space';break;
			default:_key += String.fromCharCode(_keyCode).toLowerCase();break;
		}
	}
	
	//取得当前inpupop控件的值
	var jparam = $.str2json(strparam);
	
	//在聚焦状态下启用快捷键，显示状态的为value值
	var _ipt_v = $(ipt).val();
	var _ipt_id = $("#iph_id_"+id).val();
	var _ipt_text = $("#iph_text_"+id).val();
	var _ipt_value = $("#iph_value_"+id).val();
	
	
	if(_ipt_v!=_ipt_value){
	//	alert('_ipt_v='+_ipt_v+'   _ipt_value='+_ipt_value)
	//输入值和聚焦高亮值不一致，说明是输入的
		$("#iph_id_"+id).val(_ipt_v);
		$("#iph_text_"+id).val(_ipt_v);
		$("#iph_value_"+id).val(_ipt_v);
	}
	
	_ipt_id = $("#iph_id_"+id).val();
	_ipt_text = $("#iph_text_"+id).val();
	_ipt_value = $("#iph_value_"+id).val();
	
	
	var _v = $.inputpop_getValues({id:jparam.id});
	jparam.value_id = _ipt_id;
	jparam.value_text = _ipt_text;
	jparam.value_value = _ipt_value;
	
	//调用事件句柄
	for(var shortkey in jparam.keyHandler){
		if(shortkey==_key){
			var mid = jparam.keyHandler[shortkey];
			$.method_call(mid,jparam);
		}
	}
	
	//阻止事件传递
	event.stopPropagation();  

}

function _inputpop_openwin(id){
//	_inputpop_onfocusout(id);
	
	//如果当前禁止了，则不弹出
	var isdisabled = $('#'+id).attr("disabled");
	if('disabled'==isdisabled){
		return;
	}
	var strparam = $('#iph_param_'+id).val();
	strparam = strparam.replace(/\\\'/ig,"\'");
	var jparamtmp =$.str2json(strparam);
	var jparam = jparamtmp;
	if(jparamtmp.onBeforeOpen){
		jparam = $.method_call(jparamtmp.onBeforeOpen,jparamtmp);
		if(!jparam||false==jparam){
			return false;
		}
	}
//	strparam = $('#iph_param_'+id).val();
//	strparam = strparam.replace(/\\\'/ig,"\'");
//	jparam =$.str2json(strparam);
	
	var isdisabled = $('#'+jparam.id).attr('disabled');
	if(isdisabled){
		jparam.value_disabled  = '1';
		//return false;
	}else{
		jparam.value_disabled  = '0';
	}
	var _istakevalue = $('#iph_istakevalue_'+jparam.id).val();
	var _iph_value = $('#iph_value_'+jparam.id).val();
	var _iph_text = $('#iph_text_'+jparam.id).val();
	var _iph_id = $('#iph_id_'+jparam.id).val();
	
	var _iph_value = $('#iph_value_'+jparam.id).val();
	var _iph_text = $('#iph_text_'+jparam.id).val();
	var _iph_id = $('#iph_id_'+jparam.id).val();
	var _iph_datas={};
//	alert('_iph_value='+_iph_value+'    _iph_text='+_iph_text+'   _iph_id='+_iph_id);
	var _iph_datas="";
	if(jparam.type == "tree"){
		_iph_datas = {};
		_iph_datas.value_value = _iph_value;			//因为高亮聚焦的原因，因此text和value对调存放，其中value——value为隐藏域
		_iph_datas.value_text = _iph_text;
		_iph_datas.value_id = _iph_id;

		_iph_datas.value_value_old = _iph_value;
		_iph_datas.value_text_old = _iph_text;
		_iph_datas.value_id_old = _iph_id;
		//jparam.value_id = _iph_id;
	}else{
		jparam.value_value = _iph_value;			//因为高亮聚焦的原因，因此text和value对调存放，其中value——value为隐藏域
		jparam.value_text = _iph_text;
		jparam.value_id = _iph_id;

		jparam.value_value_old = _iph_value;
		jparam.value_text_old = _iph_text;
		jparam.value_id_old = _iph_id;
	}
		
	//1、注册回调函数
	var _mid = $.method_reg(window,'_callback_inputpop_openwin',jparam);
	var _wid = $.getID();
	
	//strparam = $.json2str(jparam);
	//var urlparam = $.urlparam_encode(strparam);
	var _url = WDK_ROOT+"/module/public/inputpop.jsp?mid="+_mid;
	//_url += "&param="+urlparam;
	
	var _height = jparam.height?jparam.height:400;
	var _width = jparam.width?jparam.width:300;
	var _title = jparam.title?jparam.title:'请选择';
	
	$.openWin({
		id:_wid,
		title:_title,
		height:_height,
		width:_width,
		modal:true,
		type:'url',
		url:_url,
		param:jparam,
		iph_datas:_iph_datas
	
	});
}

function _inputpop_openwin_s(id){

	//如果当前禁止了，则不弹出
	var isdisabled = $('#'+id).attr("disabled");
	if('disabled'==isdisabled){
		return;
	}
	var strparam = $('#iph_param_'+id).val();
	strparam = strparam.replace(/\\\'/ig,"\'");
	var jparamtmp =$.str2json(strparam);
	var jparam = jparamtmp;
	if(jparamtmp.onBeforeOpen){
		jparam = $.method_call(jparamtmp.onBeforeOpen,jparamtmp);
		if(!jparam||false==jparam){
			return false;
		}
	}

	var isdisabled = $('#'+jparam.id).attr('disabled');
	if(isdisabled){
		jparam.value_disabled  = '1';
		//return false;
	}else{
		jparam.value_disabled  = '0';
	}
	var _iph_value = $('#iph_value_'+jparam.id).val();
	var _iph_text = $('#iph_text_'+jparam.id).val();
	var _iph_id = $('#iph_id_'+jparam.id).val();
	
	jparam.value_value = '';			//因为高亮聚焦的原因，因此text和value对调存放，其中value——value为隐藏域
	jparam.value_text = _iph_text;
	jparam.value_id = _iph_id;

	jparam.value_value_old = '';
	jparam.value_text_old = _iph_text;
	jparam.value_id_old = _iph_id;
	
	jparam.inittext = '';
	jparam.initvalue = '';
	//1、注册回调函数
	var _mid = $.method_reg(window,'_callback_inputpop_openwin',jparam);
	var _wid = $.getID();
	var _url = WDK_ROOT+"/module/public/inputpop.jsp?mid="+_mid;
	
	var _height = jparam.height?jparam.height:400;
	var _width = jparam.width?jparam.width:300;
	var _title = jparam.title?jparam.title:'请选择';
	$.openWin({
		id:_wid,
		title:_title,
		height:_height,
		width:_width,
		modal:true,
		type:'url',
		url:_url,
		param:jparam
	});
}

//输入弹出控件返回
function _callback_inputpop_openwin(jparam,methodparam){
	var _disabled = jparam.value_disabled;
	//如果是禁用状态，则不处理
	if('1'==_disabled){
		return false;
	}
	var _id = methodparam.id;
	$("#iph_id_"+_id).val(jparam.value_id);
	$("#iph_text_"+_id).val(jparam.value_text);
	$("#iph_value_"+_id).val(jparam.value_value);
	$("#iph_submit_"+_id).val(jparam.value_id);
	$("#"+_id).val(jparam.value_text);
	

	var _value = jparam.value_id;
	var _text = jparam.value_text;
	var _value_old = jparam.value_id_old;
	var _text_old = jparam.value_text_old;
	
//	alert('callback  _iph_text='+jparam.value_text+'    _iph_value='+jparam.value_value);
	//替换必填背景色
	if('true'==$('#'+_id).attr('isrequired')){
		if(jparam.value_id){
			$('#'+_id).attr('class','inputpop_input');
		}else{
			$('#'+_id).attr('class','inputpop_input_required');
		}
	}
	
	if((_value!=_value_old)||(_text!=_text_old)){
		$.method_call(jparam.onChangeValue,jparam);
	}
	if(jparam.callback){
		$.method_call(jparam.callback,jparam);
		//eval(jparam.callback+'('+$.json2str(jparam)+')');
	}
}


function _treegrid_export(gridcode,id,idField,eptype){
	var rows = $("#"+id).treegrid("getSelections");
	var idarr = [];
	for(var i=0;i<rows.length;i++){
		idarr.push(rows[i][idField]);
	}
	var rowid = idarr.join(',');
//	alert('gridcode='+gridcode+'   id='+id+'   eptype='+eptype+'   rowid='+rowid)
//	return false;
	$.treegrid_export_excel({
		eptype:eptype,
		gridcode:gridcode,
		id:id,
		rowid:rowid
	});
}

function grid_checkbox_onCheck(chk,handler){
//	alert(chk.checked+'   fun='+handler)
	handler(chk.checked);
}

/*************************************
 * 
 * 			打印处理脚本
 * 
 ************************************/
var CreatedOKLodop7766=null;

//====判断是否需要安装CLodop云打印服务器:====
function needCLodop(){
  try{
	var ua=navigator.userAgent;
	if (ua.match(/Windows\sPhone/i) !=null) return true;
	if (ua.match(/iPhone|iPod/i) != null) return true;
	if (ua.match(/Android/i) != null) return true;
	if (ua.match(/Edge\D?\d+/i) != null) return true;
	
	var verTrident=ua.match(/Trident\D?\d+/i);
	var verIE=ua.match(/MSIE\D?\d+/i);
	var verOPR=ua.match(/OPR\D?\d+/i);
	var verFF=ua.match(/Firefox\D?\d+/i);
	var x64=ua.match(/x64/i);
	if ((verTrident==null)&&(verIE==null)&&(x64!==null)) 
		return true; else
	if ( verFF !== null) {
		verFF = verFF[0].match(/\d+/);
		if ((verFF[0]>= 42)||(x64!==null)) return true;
	} else 
	if ( verOPR !== null) {
		verOPR = verOPR[0].match(/\d+/);
		if ( verOPR[0] >= 32 ) return true;
	} else 
	if ((verTrident==null)&&(verIE==null)) {
		var verChrome=ua.match(/Chrome\D?\d+/i);		
		if ( verChrome !== null ) {
			verChrome = verChrome[0].match(/\d+/);
			if (verChrome[0]>=42) return true;
		};
	};
      return false;
  } catch(err) {return true;};
};

//====页面引用CLodop云打印必须的JS文件：====
if (needCLodop()) {
	
	var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
	var oscript = document.createElement("script");
	oscript.src ="http://localhost:8000/CLodopfuncs.js?priority=1";
	head.insertBefore( oscript,head.firstChild );

	//引用双端口(8000和18000）避免其中某个被占用：
	oscript = document.createElement("script");
	oscript.src ="http://localhost:18000/CLodopfuncs.js?priority=0";
	head.insertBefore( oscript,head.firstChild );
};

//====获取LODOP对象的主过程：====
function getLodop(oOBJECT,oEMBED){
  var strHtmInstall="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='" +jsRoot + "/lib/Lodop6.218/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
  var strHtmUpdate="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='" +jsRoot + "/lib/Lodop6.218/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
  var strHtm64_Install="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='" +jsRoot + "/lib/Lodop6.218/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
  var strHtm64_Update="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='" +jsRoot + "/lib/Lodop6.218/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
  var strHtmFireFox="<br><br><font color='#FF00FF'>（注意：如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它）</font>";
  var strHtmChrome="<br><br><font color='#FF00FF'>(如果此前正常，仅因浏览器升级或重安装而出问题，需重新执行以上安装）</font>";
  var strCLodopInstall="<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='" +jsRoot + "/lib/Lodop6.218/CLodop_Setup_for_Win32NT.exe' target='_self'>执行安装</a>,安装后请刷新页面。</font>";
  var strCLodopUpdate="<br><font color='#FF00FF'>CLodop云打印服务需升级!点击这里<a href='" +jsRoot + "/lib/Lodop6.218/CLodop_Setup_for_Win32NT.exe' target='_self'>执行升级</a>,升级后请刷新页面。</font>";
  var LODOP;
  try{
      var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
      if (needCLodop()) {
          try{ LODOP=getCLodop();} catch(err) {};
	    if (!LODOP && document.readyState!=="complete") {alert("C-Lodop没准备好，请稍后再试！"); return;};
          if (!LODOP) {
			 if (isIE) document.write(strCLodopInstall);
			 else{
				 $.messager.alert('打印控件提示',strCLodopInstall);
			 	//document.documentElement.innerHTML=strCLodopInstall+document.documentElement.innerHTML;
	            return; 
			 }
          } else {
	         if (CLODOP.CVERSION<"2.1.6.3") { 
			if (isIE) {
				 $.messager.alert('打印控件提示',strCLodopUpdate);
				 return;
				//document.write(strCLodopUpdate);
			}else{
				 $.messager.alert('打印控件提示',strCLodopUpdate);
				//document.documentElement.innerHTML=strCLodopUpdate+document.documentElement.innerHTML
				 return;
			};
		 };
		 if (oEMBED && oEMBED.parentNode) oEMBED.parentNode.removeChild(oEMBED);
		 if (oOBJECT && oOBJECT.parentNode) oOBJECT.parentNode.removeChild(oOBJECT);	
	    };
      } else {
          var is64IE  = isIE && (navigator.userAgent.indexOf('x64')>=0);
          //=====如果页面有Lodop就直接使用，没有则新建:==========
          if (oOBJECT!=undefined || oEMBED!=undefined) {
              if (isIE) LODOP=oOBJECT; else  LODOP=oEMBED;
          } else if (CreatedOKLodop7766==null){
              LODOP=document.createElement("object");
              LODOP.setAttribute("width",0);
              LODOP.setAttribute("height",0);
              LODOP.setAttribute("style","position:absolute;left:0px;top:-100px;width:0px;height:0px;");
              if (isIE) LODOP.setAttribute("classid","clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
              else LODOP.setAttribute("type","application/x-print-lodop");
              document.documentElement.appendChild(LODOP);
              CreatedOKLodop7766=LODOP;
           } else LODOP=CreatedOKLodop7766;
          //=====Lodop插件未安装时提示下载地址:==========
          if ((LODOP==null)||(typeof(LODOP.VERSION)=="undefined")) {
               if (navigator.userAgent.indexOf('Chrome')>=0){
            	   $.messager.alert('打印控件提示',strHtmChrome);
            	   return;
            	  // document.documentElement.innerHTML=strHtmChrome+document.documentElement.innerHTML;
               }
                   
               if (navigator.userAgent.indexOf('Firefox')>=0){
            	   $.messager.alert('打印控件提示',strHtmChrome);
            	   return;
            	  // document.documentElement.innerHTML=strHtmFireFox+document.documentElement.innerHTML;  
               }
                   
               if (is64IE){ 
            	   $.messager.alert('打印控件提示',strHtm64_Install);
            	   document.write(strHtm64_Install);
            	   return;
               } else if (isIE){
            	   $.messager.alert('打印控件提示',strHtmInstall);
            	   return;
            	   //document.write(strHtmInstall);
               } else{
            	   $.messager.alert('打印控件提示',strHtmInstall);
            	   return;
                   //document.documentElement.innerHTML=strHtmInstall+document.documentElement.innerHTML
               };
               return LODOP;
          };
      };
      if (LODOP.VERSION<"6.2.1.8") {
          if (!needCLodop()){
          	if (is64IE) document.write(strHtm64_Update); else
          	if (isIE) document.write(strHtmUpdate); else
          	document.documentElement.innerHTML=strHtmUpdate+document.documentElement.innerHTML;
	    };
	    
          return LODOP;
      };
      //===如下空白位置适合调用统一功能(如注册语句、语言选择等):===
      LODOP.SET_LICENSES("","0CF8038B7CFC0A436C68D97798415AE9","C94CEE276DB2187AE6B65D56B3FC2848","");
      //===========================================================
      return LODOP;
  } catch(err) {alert("getLodop出错:"+err);};
};

/////////////////////////////////////////////////////
////////	gw_db_fy_ld    固位单表分页连打处理函数	
/////////////////////////////////////////////////////

//打印设计：固位单表分页连打
//LODOP：			控件object对象
//template：			模板内容
//jdata：			打印数据的json对象
function print_design_gw_db_fy_ld(LODOP,template,jdata){
	var _content = $.print_translate_gw_db_fy_ld(template,jdata);
	_content = unescape(_content);
	eval(_content);
}

//打印维护：固位单表分页连打
//	LODOP：			控件object对象
//	template：		模板内容
//	jdata：			打印数据的json对象
function print_setup_gw_db_fy_ld(LODOP,template,jdata){
	var _content = $.print_translate_gw_db_fy_ld(template,jdata);
	eval(_content);
}

//打印预览：固位单表分页连打
//	LODOP：			控件object对象
//	template：		模板内容
//	jdata：			打印数据的json对象
//	jpage：			页面样式json对象
function print_preview_gw_db_fy_ld(LODOP,template,jdata,jpage){
	var _pageStart = 0;
	LODOP.SET_PRINT_PAGESIZE(0,jpage.paperwidth+"mm",jpage.paperheight+"mm","");	
	var _content = template;
	while(_content){
		_content = $.print_translate_gw_db_fy_ld(template,jdata,_pageStart);
		if(null==_content||""==_content||"null"==_content){
			break;
		}
		LODOP.NewPage();
		eval(_content);
		_pageStart++;
	}
}
//打印：固位单表分页连打
//	printerIndex：	打印机序号
//	LODOP：			控件object对象
//	template：		模板内容
//	jdata：			打印数据的json对象
//	jpage：			页面样式json对象
function print_print_gw_db_fy_ld(printerIndex,LODOP,template,jdata,jpage){
	var _pageStart = 0;
	var _content = template;
	while(_content){
		_content = $.print_translate_gw_db_fy_ld(template,jdata,_pageStart);

		if(null==_content||""==_content||"null"==_content){
			break;
		}
		if(_pageStart%2==0){
			LODOP.SET_PRINT_PAGESIZE(0,jpage.paperwidth+"mm",(jpage.paperheight+jpage.offsettop)+"mm","");
		}else{
			LODOP.SET_PRINT_PAGESIZE(0,jpage.paperwidth+"mm",jpage.paperheight+"mm","");
		}

		LODOP.SET_PRINTER_INDEX(printerIndex);
		eval(_content);
		LODOP.PRINT();
		_pageStart++;
	}
}











function InsertHTML(s) {
	//alert('InsertHTML   ='+s);
    var editor = CKEDITOR.instances.myeditor; //FContent：这个对应文本域
    //alert(editor)
    if (editor.mode == 'wysiwyg') {
        editor.insertHtml(s);
    }
    CKEDITOR.dialog.getCurrent().hide();//隐藏弹出层
}